<template>
	<view class="page-container back-grey-light">
		<!-- 主要内容 -->
		<view class="content">
			<!-- 用户头像昵称 -->
			<view class="back-white mb-base col-box center" style="padding: 48rpx 0;" @click="goLogin()">
				<u-avatar :src="avatar" size="152"></u-avatar>
				<text class="s36 bold mt-base" style="letter-spacing: 1rpx;">{{ nickName?nickName:'未登录' }}</text>
			</view>
			<!-- 功能列表 -->
			<view class="back-white">
				<view class="row-box sb prow-l fun-item" @click="goEditMyInfo()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/info.png" mode="aspectFill"></image>
						<text class="ml-base">个人资料</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<view class="row-box sb prow-l fun-item" @click="goMyPost()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/post.png" mode="aspectFill"></image>
						<text class="ml-base">我的帖子</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<view class="row-box sb prow-l fun-item" @click="goMyLike()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/like.png" mode="aspectFill"></image>
						<text class="ml-base">我的点赞</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<!-- <view class="row-box sb prow-l fun-item" @click="goMyOrder()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/order.png" mode="aspectFill"></image>
						<text class="ml-base">我的订单</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view> -->
				<view class="row-box sb prow-l fun-item" @click="goMyAddress()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/address.png" mode="aspectFill"></image>
						<text class="ml-base">我的地址</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<view class="row-box sb prow-l fun-item" @click="goIdentify()">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/identify.png" mode="aspectFill"></image>
						<text class="ml-base">身份认证</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<!-- <view class="row-box sb prow-l fun-item">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/user.png" mode="aspectFill"></image>
						<text class="ml-base">用户协议</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view> -->
				<view class="row-box sb prow-l fun-item" @click="goMyApplySettle()">
					<view class="row-box">
						<image class="icon48" :src="`../../static/icon/${userType?'manage':'settle'}.png`" mode="aspectFill"></image>
						<text class="ml-base">{{ userType?'店铺管理':'开通商家' }}</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
				<view class="row-box sb prow-l fun-item" @click="makePhone('15375602236')">
					<view class="row-box">
						<image class="icon48" src="../../static/icon/contact.png" mode="aspectFill"></image>
						<text class="ml-base">联系管理</text>
					</view>
					<u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
				</view>
			</view>
		</view>
		
		<!-- 发布分类选择 -->
		<!-- <u-select
			v-model="showPublishCateSelect"
			:list="publishCates"
			value-name="id"
			label-name="name"
			title="请选择分类"
			confirm-text="去发布"
			:confirm-color="primaryColor"
			@confirm="selectPublishCate">
		</u-select> -->
		
		<!-- 自定义tabbar -->
		<!-- <u-tabbar :list="tabbar" :mid-button="true" active-color="#1BBBAF" inactive-color="#333333"
			:border-top="false" icon-size="54" mid-button-size="94" height="62px" :before-switch="beforeChangeTab">
		</u-tabbar> -->
	</view>
</template>

<script>
	import { mapState,mapMutations } from "vuex"
	export default {
		data() {
			return {
				qrcode: 'https://image.chongdu.com/15727b3f-ac54-435c-b465-59ee58ee7e32.jpg', // 联系二维码
				
			}
		},
		computed: {
			...mapState('m_page', ['tabbar', 'publishCates']),
			...mapState('m_user', ['token', 'userId', 'nickName', 'avatar', 'isAuthent', 'userType']),
		},
		onLoad() {
			
		},
		onShow() {
			// 获取所有角标并处理订单角标
			// this.orderBadgeHandle()
			// 设置底部tabbar消息角标
			this.setBadge()
			// 获取用户详情
			this.getUserInfo()
		},
		methods: {
			...mapMutations('m_page', ['updateBeforeChangeTab']),
			...mapMutations('m_user', ['updateUserType']),
			
			// 处理订单角标
			// async orderBadgeHandle() {
			// 	let res = await this.getAllBadge()
			// 	this.funList[0].list[0].toast = res.waitPay
			// 	this.funList[0].list[1].toast = res.waitSend
			// 	this.funList[0].list[2].toast = res.waitGet
			// 	this.funList[0].list[3].toast = res.waitComment
			// 	this.funList[0].list[4].toast = res.afterSalesCount
			// },
			
			// 跳转登录
			goLogin() {
				if (!this.token) {
					return this.gotoLogin()
				}
				// 编辑资料
				this.goEditMyInfo()
			},
			
			// 跳转编辑个人信息
			goEditMyInfo() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: '/pages/subPackage/user/my_userinfo/my_userinfo'
				})
			},
			
			// 跳转我的帖子
			goMyPost() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: `/pages/subPackage/user/my_post/my_post`
				})
			},
			
			// 跳转我的点赞
			goMyLike() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: `/pages/subPackage/user/my_like/my_like`
				})
			},
			
			// 跳转身份认证
			goIdentify() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: '/pages/subPackage/user/my_identify/my_identify'
				})
			},
			
			// 跳转我的订单
			goMyOrder() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: `/pages/subPackage/user/my_order/my_order?type=${0}`
				})
			},
			
			// 跳转我的地址
			goMyAddress() {
				if (!this.token) {
					return this.gotoLogin()
				}
				uni.navigateTo({
					url: `/pages/subPackage/user/my_address/my_address`
				})
			},
			
			// 跳转开通商家
			goMyApplySettle() {
				if (!this.token) {
					return this.gotoLogin()
				} else if (!this.isAuthent) { // 用户未实名
					uni.showModal({
						content: `未实名不能回复！确定前往实名？`,
						confirmColor: this.primaryColor,
						success: (res) => {
							if (res.confirm) {
								uni.navigateTo({
									url: `/pages/subPackage/user/my_userinfo_bind/my_userinfo_bind?type=${2}`
								})
							}
						}
					})
				} else if (this.userType) { // 用户已入驻商家
					return uni.navigateTo({
						url: '/pages/subPackage/merchant/index/index'
					})
				}
				uni.navigateTo({
					url: `/pages/subPackage/user/my_apply_settle_certificate/my_apply_settle_certificate`
				})
			},
			
			// 获取用户详情
			getUserInfo() {
				this.$api.GetUserInfo().then(res => {
					console.log('GetUserInfo-success', res)
					if (res.data.code == 200) {
						this.updateUserType(res.data.data.type)
					} else {
						// uni.showToast({
						// 	icon: 'none',
						// 	title: res.data.msg
						// })
					}
				}).catch(err => {
					console.log('GetUserInfo-fail', err)
				})
			}
		}
	}
</script>

<style lang="scss">
	
	// 功能项
	.fun-item {
		height: 84rpx;
		border-bottom: 1rpx solid #f2f2f2;
		&:last-child {
			border-bottom: none;
		}
	}
</style>
